<template>
  <div class="home">
    <div>
      <div>
        <h5>window.addEventListener('unhandledrejection', () => {})</h5>
        <div>
          <el-button id="commonPromiseError" @click="PromiseErrorFunc">PromiseRejection错误</el-button>
          <el-button id="commonPromiseError" @click="network500Error">500错误</el-button>
          <el-button id="commonPromiseError" @click="network404Error">404错误</el-button>
          <el-button @click="networkTimeout">3秒超时</el-button>
        </div>

        <h5>window.addEventListener('error', (error) => {})</h5>
        <div>
          <el-button @click="loadResError">加载不存在的资源</el-button>
        </div>

        <h5>Vue.config.errorHandler</h5>
        <el-button @click="vueErrorFunc">vue2异常</el-button>
      </div>

      <!-- <el-button @click="commonErrorFunc">运行异常</el-button> -->
      <!-- <el-button @click="vueErrorFunc">vue2异常</el-button> -->

     
      
      <!-- <el-button @click="networkFetchError">fetch</el-button> -->
      <img v-if="showRes" src="http://localhost:8080/image/cctv.png">
      <!-- <el-button @click="testVue">3秒1超时</el-button> -->
    </div>

  </div>
</template>

<script>
// @ is an alias to /src
/*eslint-disable*/
import { Button } from 'element-ui';

import axios from 'axios'
import Utils from "../utils"
import api from "../utils/api"



export default {
  name: 'HomeView',
  components: {
    elButton: Button,
    // HomeView,
  },
  mounted() {

  },

  data() {
    return {
      showRes: false
    };
  },
  computed: {
  },
  methods: {

    loadResError() {
      this.showRes = true;
    },
    commonErrorFunc() {
      console.log(a)
    },  
    vueErrorFunc() {
      // Utils.commonErrorFunc()
      console.log(this.showRes())
    },
    PromiseErrorFunc() {
      Promise.reject("PromiseErrorFunc")
    },

    network500Error() {
      this.$http.get(api.GET_500).then(res=>{
        console.log(res.data)
      })
    },

    network404Error() {
      this.$http.get(api.GET_404).then(res=>{
        console.log(res.data)
      })

    },
    networkTimeout() {
      this.$http.get(api.GET_TIMEOUT, {timeout: 3000}).then(res=>{
        console.log(res.data)
      })

    },

    // networkFetchError() {
    //   fetch(api.GET_404).then(res=>{
    //     console.log(res.data)
    //   })
    // }
  }
}
</script>
